<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>WS库存报表</title>

		<link href="../../rs/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
		<link href="../../rs/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
		<link href="../../rs/plugins/bootstrap_tab/css/bootstrap-table.css" rel="stylesheet">
		<link href="../../rs/css/animate.min.css" rel="stylesheet">
		<link href="../../rs/css/style.min862f.css?v=4.1.0" rel="stylesheet">
		<link href="../../rs/plugins/datapicker/datepicker3.css" rel="stylesheet">
		<link href="../../rs/plugins/bootstrap-editable/css/bootstrap-editable.css" rel="stylesheet">

    <style>
        #toolbar1 {
            padding: 10px 15px;
            float: right;
        }
        .btn-group-sm > .btn, .btn-sm {
            padding: 5px 12px;
        }

        .editable-click, a.editable-click, a.editable-click:hover {
            border-bottom: 0px;
        }
        .fixed-table-pagination .page-list{
            display: none;
        }
    </style>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <!-- Panel Other -->
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div style="display: block;">
                <div class="col-sm-3" style="padding-left: 0px;">
                    <div class="input-group ">
                        <span class="input-group-btn">
                            <button style="height:34px;background-color: #FFF;border: 1px solid #e5e6e7;font-size: 14px" type="button" class="btn btn-sm ">门 店</button>
                        </span>
                        <select class="form-control" id="mdbh">
                        </select>
                    </div>
                </div>
                <button id="reflash" style="height:34px;margin-bottom: 0px;margin-right: 5px;border-radius: 3px;" type="button" class="btn btn-sm"> 刷新</button>
            </div>
            <table id="table"></table>
            <!-- End Example Card View -->
        </div>
    </div>
</div>
<!-- End Panel Other -->


<script src="../../rs/js/jquery.min.js"></script>
<script src="../../rs/js/bootstrap.js"></script>
<script src="../../rs/plugins/bootstrap_tab/js/bootstrap-table.min.js"></script>
<script src="../../rs/plugins/bootstrap_tab/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
<script src="../../rs/plugins/datapicker/bootstrap-datepicker.js"></script>
<script src="../../rs/plugins/bootstrap_tab/js/bootstrap-table-export.js"></script>
<script src="../../rs/plugins/bootstrap_tab/js/tableExport.js"></script>
<script src="../../rs/js/jquery.cookie.js"></script>
<script src="../../rs/js/common_qj.js"></script>
<script src="../../rs/plugins/layer/layer.min.js"></script>
<script src="../../rs/plugins/bootstrap-editable/js/bootstrap-editable.js"></script>
<script src="../../rs/plugins/bootstrap-editable/js/bootstrap-table-editable.min.js"></script>

<script type="text/javascript">
    var $table = $('#table');
    var $remove = $('#remove');
    var sign = URLencode($.cookie('sign'));

    $(function () {

        var start = (new Date()).format('yyyy-MM-dd');
        $('#start').val(start);
        $('#table').bootstrapTable({
            columns: [
                {
                    field: 'shbh',
                    align: 'center',
                    title: '门店',
                    width:'50px'
                },
                {
                    field: 'prid',
                    title: '商品编号',
                    align: 'center',
                    width:'90px',
                    footerFormatter: ftm
                },
                {
                    field: 'prname1',
                    align: 'left',
                    title: '商品名称'
                },
                {
                    field: 'kc',
                    align: 'center',
                    title: '库存',
                    width:'70px',
                    footerFormatter: ft
                }
            ],
            pagination: true,
            advancedSearch: true,
            idTable: "advancedTable",
            shadeClose: true,
            toggle: "table",
            showExport:true,
            uniqueId: "id",
            height: "400",
            showFooter:true
        });
        f_sheard();
    });


    var dtnheard = {};
    function f_sheard() {
        layer.load(2);
        $.ajax({
            type: "post",
						url:G_url+'sysg/see',
						data: 'sign=' + sign,
            dataType: "json",
            success: function (aftdata) {
                layer.closeAll('loading');
                if (!aftdata.ok) {
                    layer.msg(aftdata.msg);
                    if (aftdata.code == '1000') {
                        $.cookie('sign', '', {expires: -1});
                        $.cookie('username', '', { expires: -1 });
                        window.location.href = 'login.html';
                        return;
                    }
                }
                dtnheard = aftdata;
                $('#table').bootstrapTable('load', dtnheard.data);

                var ss = dtnheard.sysh;
                var html = '';
                var aa=0;
                $.each(ss, function (a, b) {//直接取出json的prolist做each循环.
                    html += "<option value='"+ ss[aa].shbh+"'>" + b.shmc + "</option>";//拼接字符串.
                    aa++;
                });
                $("#mdbh").append(html);
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
            }
        });
    }


    function ftm(dt) {
        return "总计";
    }

    function ft(dt){
        if (dt.length==0) return;
        var jj=JSON.stringify(dtnheard.footer);
        var jsonobj=eval('('+jj+')');
        return jsonobj[this.field];
    }


    var dd = 'all';
    $("#mdbh").change(function () {
        layer.confirm('确定要选择这个门店吗？', {
            title: [''],
            btn: ['确定', '取消'] //按钮
        }, function (index) {
            var cz = $("#mdbh  option:selected").val();
            dd=cz;
            f_detail(cz);
            layer.close(index);
        }, function () {
            $("#mdbh").val(dd);
        });
    });


    $("#reflash").click(function(){
        var cz = $("#mdbh  option:selected").val();
        f_detail(cz);
    });


    var dtn = [];
    var sign1=$.cookie('sign');
    function f_detail(shbh) {
        layer.msg('数据加载中...', {icon: 16, time: 200000, shade: [0.1, 'black']});
        $.ajax({
            type: "post",
            url: G_url+'Sysc',
            data: 'shop=' + shbh + '&sign=' + sign,
            dataType: "json",
            success: function (aftdata) {
                layer.closeAll();
                if (!aftdata.ok) {
                    layer.msg(aftdata.msg);
                    if (aftdata.code == '1000') {
                        $.cookie('sign', '', {expires: -1});
                        $.cookie('username', '', { expires: -1 });
                        window.location.href = 'login.html';
                        return;
                    }
                }
                dtn = aftdata.data;
                dtnheard=aftdata;
                $('#table').bootstrapTable('load', dtn);
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
            }
        });
    }
</script>
</body>
</html>
